#include<bits/stdc++.h>
using namespace std;
typedef struct{
	int a,h;
}AD;
bool cmp(AD A,AD B)
{
	return A.a < B.a;
}
AD a[200011];
long long st[21][200011];
long long f[200011];
int lg[200011];
void Insert(int p)
{
	st[0][p] = f[p];
	for(int k = 1;(1 << k) <= p;k++)
		st[k][p - (1 << k) + 1] = min(st[k - 1][p - (1 << k) + 1],st[k - 1][p - (1 << (k - 1)) + 1]);
}
long long ask(int l,int r)
{
	int len = r - l + 1,k = lg[len];
	return min(st[k][l],st[k][r - (1 << k) + 1]);
}
int rt[200011];
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("xinyue.in","r",stdin);
	freopen("xinyue.out","w",stdout);
	cin >> n;
	cin >> a[++n].a;
	a[n].h = 1;
	for(int i = 2;i <= n;i++)
		lg[i] = lg[i >> 1] + 1;
	for(int i = 1;i < n;i++)
		cin >> a[i].a >> a[i].h;
	sort(a + 1,a + n + 1,cmp);
	long long ans = 0;
	for(int i = 1;i <= n;i++)
	{
		for(int j = a[i - 1].a;j < a[i].a;j++)
			rt[j] = i - 1;
		a[i].h--;
		if(a[i].h)
		{
			f[i] = 1ll * (a[i].h - a[i].h / a[n].a) * a[i].a;
			ans += 1ll * (a[i].h / a[n].a) * a[i].a;
			for(int l = 1,r;l < a[i].a;l = r + 1)
			{
				if(l == a[i].h + 1)
					r = a[i].a - 1;
				else
					r = min(a[i].h / (a[i].h / l),a[i].a - 1);
				int L = rt[l - 1] + 1,R = rt[r];
				if(L <= R)
					f[i] = min(f[i],ask(L,R) + 1ll * (a[i].h / l - a[i].h / a[n].a) * a[i].a);
			}
		}else
			f[i] = 0;
		Insert(i);
	}
	long long res = f[n];
	for(int i = n - 1;a[i].a == a[n].a;i--)
		res = min(res,f[i]);
	cout << ans + res;
	return 0;
}
